package y23.Oct;

public class Test5 {
    public static void main(String[] args) {
        System.out.println(chkParenthesis("((()))", 6));
    }
    public static boolean chkParenthesis(String A, int n) {
        int i = 0;
        int count1=0;
        int count2=0;
        while (i < n){
            if(A.charAt(i) =='('){
                count1++;
            }else if(A.charAt(i) == ')'){
                count2++;
            }else{
                return false;
            }
            i++;
        }
        if(count1 == count2){
            return true;
        }else{
            return false;
        }
    }
}
